window.onload = function() {
	var arrDivs = document.getElementsByTagName("div");

	for (var i = 0; i < arrDivs.length; i++) {
		// var arrDivs[i].widthTimer = null;//错误
		//widthTimer是aaDiv中每个元素都有的属性，每一个div定义一个widthTimer
		arrDivs[i].widthTimer = null;
		arrDivs[i].transpTimer = null;
		arrDivs[i].alpha = 100;
		arrDivs[i].onmouseover = function() {
			
			Move(this, 800, 30);

		}
		arrDivs[i].onmouseout = function() {
			Move(this, 200, 100);
		}
	}
}

// var alpha; //多物体运动，不能共用

function Move(obj, widthTarget, transpTarget) {



	var arrDivs = document.getElementsByTagName("div");
	clearInterval(obj.widthTimer);
	clearInterval(obj.transpTimer);
	//宽度变化
	obj.widthTimer = setInterval(function() {
		var speed;
		speed = (widthTarget - obj.offsetWidth) / 20; //速度变化
		speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed); //速度为正，向上取整;为负，向下取整
		obj.style.width = obj.offsetWidth + speed + "px";
	}, 20);
	//透明度变化
	obj.transpTimer = setInterval(
		function() {
			var speed;
			if (obj.alpha > transpTarget) {
				speed = 10;
			} else {
				speed = -10;
			}
			if (obj.alpha == transpTarget) {
				clearInterval(transpTimer);
			} else {
				obj.alpha += speed;
				obj.style.opacity = obj.alpha / 100;
				obj.style.filter = "(opacity: " + obj.alpha + ")";
			}
		}, 80);
}